package cn.rongdao.jrkabao.ui.main.mainfragment.cashadvance.ui;

import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.mifengkong.frtools.util.FRImageLoad;

import cn.rongdao.jrkabao.R;
import cn.rongdao.jrkabao.bean.cashadvance.HomeBean;

/**
 * Created by WANG on 17/12/19.
 */

public class LoanItemComponent extends RelativeLayout {
    public LoanItemComponent(Context context) {
        super(context);
    }

    public LoanItemComponent(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public LoanItemComponent(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }
    private ImageView loanLogo;
    private TextView loanQuota; //可贷额度
    private TextView loanProductName;
    private TextView loanProductDetail;
    private TextView loanProductHotTag;
    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        loanLogo = (ImageView) findViewById(R.id.loan_itemLogo);
        loanQuota = (TextView) findViewById(R.id.loan_itemMoney);
        loanProductName = (TextView) findViewById(R.id.loan_itemProductName);
        loanProductDetail = (TextView) findViewById(R.id.loan_itemProductDetail);
        loanProductHotTag = (TextView) findViewById(R.id.loan_itemProductHotTag);
    }

    public void setData(HomeBean.LoanCommendBean loanCommendBean){
        String desc2 = loanCommendBean.getDesc_amount();  //可贷额度
        String desc1 = loanCommendBean.getDesc_title();  //推荐理由
        String logo = loanCommendBean.getLogo();    //贷款icon
        String config_cn = loanCommendBean.getConfig_cn(); //贷款的名称
        String corner = loanCommendBean.getCorner();   //是否显示热门标签

        if(TextUtils.isEmpty(corner)){
            loanProductHotTag.setVisibility(GONE);
        }else {
            loanProductHotTag.setVisibility(VISIBLE);
            loanProductHotTag.setText(corner);
        }
        loanProductName.setText(config_cn);
        loanProductDetail.setText(desc1);
        loanQuota.setText(desc2);
        if(!TextUtils.isEmpty(logo)){
            FRImageLoad.loadImage(logo,loanLogo,R.drawable.icon_loan_placeholder);
        }

    }

}
